﻿using AJWPFAdmin.Core.CommonEntity;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AJWPFAdmin.Core.Excel;

namespace AJWPFAdmin.Core.Models.EF.Tables
{
    /// <summary>
    /// 系统自定义字典表
    /// </summary>
    [Comment("系统自定义字典表")]
    public partial class SystemDictionary : CommonTableEntity
    {
        public SystemDictionary()
        {
            Children = new List<SystemDictionary>();
        }

        /// <summary>
        /// 编号
        /// </summary>
        [Comment("编号")]
        [Display(Name = "编号")]
        [Required(ErrorMessage = "{0}必填")]
        [MaxLength(20)]
        [StringLength(20, ErrorMessage = "{0}超长:{1}")]
        [AJExportField(ColumnName = "编号", ColumnIndex = 1)]
        [AJImportField(ColumnName = "编号", ColumnIndex = 1)]
        public string Code { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        [Comment("名称")]
        [Display(Name = "名称")]
        [Required(ErrorMessage = "{0}必填")]
        [MaxLength(20)]
        [StringLength(20, ErrorMessage = "{0}超长:{1}")]
        [AJExportField(ColumnName = "名称", ColumnIndex = 1)]
        [AJImportField(ColumnName = "名称", ColumnIndex = 1)]
        public string Name { get; set; }

        /// <summary>
        /// 父级Id
        /// </summary>
        [Comment("父级Id")]
        public long? ParentId { get; set; }

        /// <summary>
        /// 关联父级数据
        /// </summary>
        [ForeignKey("ParentId")]
        public SystemDictionary Parent { get; set; }

        /// <summary>
        /// 序号，越小越靠前
        /// </summary>
        [Comment("序号")]
        public short SortNo { get; set; }

        /// <summary>
        /// 子集列表
        /// </summary>
        [Comment("子集列表")]
        public virtual IList<SystemDictionary> Children { get; set; }
    }
}
